package com.y.web.thread;

import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;

import java.util.concurrent.*;

public class ThreadConfig {
    private final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(4, 8, 100L, TimeUnit.SECONDS, new LinkedBlockingDeque<>(10));

    public static void main(String[] args) {
        new ThreadConfig().runThread();

    }

    public void runThread(){
        try {
            Task task = new Task();
            Future<?> submit = threadPoolExecutor.submit(task);
            Object o = submit.get();
            System.out.println(o);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
}
